var $ = require('../../lib/jquery');
var util = require('./common/util');
var nav = require('./common/nav');
var _header = require('./common/header');
var template = require('../tpl/template');
var minHeight = require('./common/minHeight');
minHeight.init();
var _nav = new nav();
var header = new _header();
if(util.getParam('type')==1){
getList();
}else{
getList1();
}


$('.js_back').on('click',function(){
    history.back();
})
  function time() {
     var date = new Date();
     var y = date.getFullYear();
     var m = date.getMonth() + 1;
     m = m < 10 ? ('0' + m) : m;
     var d = date.getDate();
     d = d < 10 ? ('0' + d) : d;
     return y + '-' + m + '-' + d;
 };
 //血糖
function getList(){
    util.fetch('api/blood/queryHistoryList', {
        addDate: time(),
        page:1,
        pageSize:7,
        egoId:1,
        sign:2,
        paramType:1
    }).then(function(res){
         var arr = [];
         for (var value in res.data[0]) {
             arr.push(res.data[0][value][0])
         }
         var m = template('xtjl', {
             data: arr
         });
       
         $('.js_date_wrap').html(m);
    }).fail(function () {
        $('.noword').removeClass('hide');
        $('.con').hide();

    })
 }
 //血压
 function getList1(){
    util.fetch('api/blood/queryHistoryList', {
       addDate: time(),
        page: 1,
        pageSize: 7,
        egoId: 1,
        sign: 2,
        paramType: 2
    }).then(function(res){
         var m = template('xyjl', {
             data: res.data
         });
         $('.js_date_wrap').html(m);
    }).fail(function () {
        $('.noword').removeClass('hide');
        $('.con').hide();

    })
 }